package com.contactmgr.activity;

import java.util.List;

import android.app.Activity;
import android.os.Bundle;

import com.contactmgr.R;
import com.contactmgr.logObjects.CallDataLog;
import com.contactmgr.logObjects.Contact;
import com.contactmgr.logObjects.Sms;
import com.contactmgr.utils.CallLogReader;
import com.contactmgr.utils.ContactNameResolver;
import com.contactmgr.utils.ContactReader;
import com.contactmgr.utils.SmsReader;

public class MainActivity extends Activity {
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		List<Contact> contactList = ContactReader.getContacts(getContentResolver());
		for (Contact contact : contactList) {
			System.out.println(contact.toString());
		}
		System.out.println("@@@@@@@@@@@@@@@@");
		List<Sms> inbox = SmsReader.readInbox(getContentResolver());
		List<Sms> sentItems = SmsReader.readSentItems(getContentResolver());
		List<Sms> inboxResolved = ContactNameResolver.resolveNamesInSms(contactList, inbox);
		List<Sms> sentItemsResolved = ContactNameResolver.resolveNamesInSms(contactList, sentItems);
		System.out.println("@@@@@@@@@@@@@@@@");
		for (Sms sms : sentItemsResolved) {
			System.out.println(sms);
		}
		System.out.println("@@@@@@@@@@@@@@@@");
		for (Sms sms : inboxResolved) {
			System.out.println(sms);
		}
		System.out.println("@@@@@@@@@@@@@@@@");
		List<CallDataLog> callLog=CallLogReader.getAllCallLogs(getContentResolver());
		List<CallDataLog> nameResolvedCallData = ContactNameResolver.resolveNamesInCallLog(contactList, callLog);
		for (CallDataLog callDataLog : nameResolvedCallData) {
			System.out.println(callDataLog.toString());
		}

	}
}